package com.hengmei.smallscreen.utils

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.orhanobut.logger.Logger
import java.text.SimpleDateFormat
import java.util.Date

const val BASE_URL = "https://hengmei.com/"
const val ISBAN = "ISBAN"
const val PHOTO_PATH = "/Pictures/back.jpg"
const val SPLASHTIME = 8000L //闪屏时间

fun inflate(
    context: Context,
    viewId: Int,
    parent: ViewGroup? = null,
    attachToRoot: Boolean = false
): View {
    return LayoutInflater.from(context).inflate(viewId, parent, attachToRoot)
}

fun Context.toast(message: String, length: Int = Toast.LENGTH_SHORT) {
    Toast.makeText(this, message, length).show()
}
fun log(message: String) {
    Logger.d(message)
}

fun getCode():String {
    return android.os.Build.SERIAL
}
fun getTime(): String {
    val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") // HH:mm:ss

    val date = Date(System.currentTimeMillis())
    return simpleDateFormat.format(date)
}
fun <T> MutableLiveData<T>.asLiveData(): LiveData<T> {
    return this
}
